<?php 
	include_once '../../LMSController/LMSAdminRequestController/LMSBookRequestController.php';
    session_start();
?>
<html>
	<head>
		<title>
			Admin Home Page
		</title>
        <script>
		
		 function issueBook(bookID)
		 {
			window.location.href = "../../LMSController/LMSAdminRequestController/LMSBookIssueController.php?BookID="+bookID;
		 }
		 
		</script>
	</head>
	<body>
    <center>
        <?php
				//retrieve session data
				print "<h2>Admin Home page</h2>  <p align=\"left\">LoggedIn As : ".$_SESSION['ID']."</p>";
		?>
    </center>
    <hr/>
    <h3> Menus should place here </h3>
    <hr/>
	    <?php
				$BookRequestObject = new LMSBookRequestController();
				$data = $BookRequestObject->getBookRequestModel();
				$counter = 0;
				echo "<table border=\"1\" cellpadding=\"5\" >";
				
				while($row = mysql_fetch_array($data))
					{
						if(($counter == 0)&&($row['Flag'] == 0))
						{
							echo "<tr><th>Student Name</th><th>Book Name</th><th>Edition Number</th><th>Author Name</th><th>publication</th></tr>";
							$counter++;
						}
						if($row['Flag'] == 0)
						{
							$bookID = $row['bookID'];
							echo "<tr>";
							echo "<td>".$row['studentName']."</td>";
							echo "<td>".$row['bookName']."</td>";
							echo "<td>".$row['editionNumber']."</td>";
							echo "<td>".$row['authorName']."</td>";
							echo "<td>".$row['publication']."</td>";
							echo "<td><input type=\"submit\" id=\"button\" value=\"Issue\" onClick=\"issueBook($bookID)\" /></td>";
							echo "<td></td>";
							echo "</tr>";
						}
					}
				echo "</table>";
				if($counter == 0)
				{
					echo "NO BOOK REQUESTS ARE MADE";
				}
			?>
	</body>
</html>